package com.lzq.streamdemo.stream;

import com.lzq.streamdemo.entity.Man;

import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class getStream {
    public static void main(String[] args) {
        //1.单列集合获取stream流
        /*List<String> list = new ArrayList();
        Stack<String> stack = new Stack<>();
        Collections.addAll(stack,"111","333","222");
        Stream<String> stream = stack.stream();
        stream.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });*/

        //2.双列集合获取stream流
        /*Map<String,String> map = new HashMap<>();
        map.put("1","111");
        map.put("2","222");
        map.put("3","333");
        map.keySet().stream().forEach(s-> System.out.println(s + " " +map.get(s)));
        map.entrySet().stream().forEach(s-> System.out.println(s));*/

        //3.数组stream流
/*        int[] arr1 = {1,2,3,4,5};
        String[] arr2 = {"a","b","c","d"};
        Arrays.stream(arr1).forEach(System.out::println);
        Arrays.stream(arr2).forEach(System.out::println);*/

        //4.(同类型)零散数据
        Man man1 = new Man(20,180);
        Man man2 = new Man(35,170);
        Stream.of(man1,man2).forEach(System.out::println);
    }
}
